﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using PlugNT.Cms.Core;
using PlugNT.Cms.BLL;
using PlugNT.Cms.Model;
using PlugNT.Cms.Page;

namespace PlugNT.Cms.Web.Admin.Pre_GroupPages
{
    public partial class Add : AdminPage
    {
        private GroupPages curGroupPages = new GroupPages();

        protected void Page_Load(object sender, EventArgs e)
        {
            //权限检测
            this.CheckPower();

        }

     
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string codeno = hidPageCode.Value.Trim();
            if (codeno.StartsWith(HtmlLabel.powerCode) && codeno.EndsWith(HtmlLabel.powerCode))
            {
                codeno = codeno.Replace(HtmlLabel.powerCode, "");
            }
            else
            {
                codeno = "";
            }


            if (codeno != "")
            {
                GroupPagesInfo model = new GroupPagesInfo();

                model.codeno = codeno;
                model.pagename = txtPageName.Text.Trim();
                model.pagepath = txtPagePath.Text.Trim();
                model.groupname = txtGroupName.Text.Trim();

                if (!curGroupPages.Exist(model.codeno))
                {
                    if (curGroupPages.Add(model))
                    {
                        Response.Redirect("../Message.aspx?message=添加授权页成功！&z=yes");
                    }
                    else
                    {
                        Response.Redirect("../Message.aspx?message=添加授权页失败！&z=no");
                    }
                }
                else
                {
                    Response.Redirect("../Message.aspx?message=添加授权页失败，数据库中已有记录！&z=no");
                }

            }
            else
            {
                Response.Redirect("../Message.aspx?message=添加授权页失败！&z=no");
            }
        }





    }
}
